package com.jdzy.student.controller;

import com.jdzy.model.common.vos.Result;
import com.jdzy.model.student.dtos.ResearchTopicDeleteDto;
import com.jdzy.model.student.dtos.ResearchTopicDto;
import com.jdzy.model.student.dtos.ResearchTopicSearchDto;
import com.jdzy.student.service.ResearchTopicService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("api/researchTopic")
@Api(value = "ResearchTopic的controller类")
public class ResearchTopicController {
    @Autowired
    private ResearchTopicService researchTopicService;

    /**
     * 获取课题信息
      * @param stuId
     * @param page
     * @param size
     * @param researchTopicSearchDto
     * @return
     */
    @PostMapping("getResearchTopicByStuId/{stuId}/{page}/{size}")
    public Result getResearchTopicByStuId(@PathVariable String stuId, @PathVariable Integer page
            , @PathVariable Integer size, @RequestBody ResearchTopicSearchDto researchTopicSearchDto){
        log.info("获取课题信息,参数:{},{},{},{}",stuId,page,size,researchTopicSearchDto);
        return researchTopicService.getResearchTopicByStuId(stuId,page,size,researchTopicSearchDto);
    }

    /**
     * 删除课题信息
     * @param stuId
     * @param researchTopicDeleteDto
     * @return
     */
    @DeleteMapping("deleteResearchTopic/{stuId}")
    public Result deleteResearchTopic(@PathVariable String stuId, @RequestBody ResearchTopicDeleteDto researchTopicDeleteDto){
        log.info("删除课题信息,参数:{},{}",stuId,researchTopicDeleteDto);
        return researchTopicService.deleteResearchTopic(stuId,researchTopicDeleteDto);
    }

    /**
     * 新增课题信息
     * @param researchTopicDto
     * @return
     */
    @PostMapping("saveResearchTopic")
    public Result saveResearchTopic(@RequestBody ResearchTopicDto researchTopicDto){
        log.info("新增课题信息,{}",researchTopicDto);
        return researchTopicService.saveResearchTopic(researchTopicDto);
    }

    /**
     * 修改课题信息
     * @param researchTopicDto
     * @return
     */
    @PostMapping("updateResearchTopic")
    public Result updateResearchTopic(@RequestBody ResearchTopicDto researchTopicDto){
        log.info("修改课题信息,{}",researchTopicDto);
        return researchTopicService.updateResearchTopic(researchTopicDto);
    }
}
